import Vue from 'vue'
import VueRouter from 'vue-router'

import index from '@/components/index'
import news from '@/components/news'
import classify from '@/components/classify'

import news1 from '@/childen/news1'
import news2 from '@/childen/news2'
import news3 from '@/childen/news3'
 
 
 import error404 from '@/error/error404'
 
Vue.use(VueRouter)
 
 export default new VueRouter({
	 mode: 'history', // 把地址栏 # 去掉
	 routes: [
	 {
	 		path: '/',
			name: 'index',
			alias: '/index',
	 		component: index
	 	},
		{
	 		path: '/news',
	 		component: news,
			children: [
				{
					path: '/',
					name: 'news1',
					alias: '/news1',
					component: news1
				},
				{
					path: 'news2',
					name: 'news2',
					component: news2
				},
				{
					path: 'news3',
					name: 'news3',
					component: news3
				}
			]
	 	},{
	 		path: '/classify',
			name: 'classify',
	 		component: classify,
			beforeEnter:(to,from,next) => {
				console.log(to);
				console.log(from);
				next(); // next(false) 不可以
			}
			
			// alias: '/aaa',  //路由别名
			// redirect: 'index' //路由重定向
	 	},{
	 		path: '*',     //404 路由跳不过去，跳转此页面
	 		component: error404,
	 	}
	 ]
})
